import { ReserveParams } from '/@/views/reserve/types'
import request from '/@/api/axios'

export function publishSave(params: ReserveParams[] = []) {
  const url = '/api/blade-appointment/appointment/publish/save'

  return request.post(url, params)
}

export function publishUpdate(params: ReserveParams) {
  const url = '/api/blade-appointment/appointment/publish/update'

  return request.post(url, params)
}

export function publishQuery(params = {}) {
  const url = '/api/blade-appointment/appointment/publish/query'

  return request.get(url, { params })
}

export function receiveQuery(params = {}) {
  const url = '/api/blade-appointment/appointment/receive/query'

  return request.get(url, { params })
}

export function receiveSave(params = {}) {
  const url = '/api/blade-appointment/appointment/receive/save'

  return request.post(url, params)
}

export function publishRemove(ids: string[]) {
  if (ids.length === 0) {
    return
  }
  const url = `/api/blade-appointment/appointment/publish/remove?ids=${ids.join(
    ','
  )}`

  return request.post(url, { ids: ids.join(',') })
}

export function getpublishQueryList(params = {}) {
  return request({
    url: '/api/blade-appointment/appointment/publish/list',
    method: 'get',
    params,
  })
}

export function getRecordOrder(current: number, size: number, params = {}) {
  return request({
    url: '/api/blade-appointment/appointment/receive/findTeacherReceiveList',
    method: 'get',
    params: {
      current,
      size,
      ...params,
    },
  })
}

export function submitServiceReport(data = {}) {
  return request({
    url: '/api/blade-appointment/advisory/report/save',
    method: 'post',
    data,
  })
}

export function submitServiceFeedback(data = {}) {
  return request({
    url: '/api/blade-appointment/advisory/feedback/save',
    method: 'post',
    data,
  })
}

export function getServiceRecord(current: number, size: number) {
  return request({
    url: '/api/blade-appointment/advisory/records/list',
    method: 'get',
    params: {
      size,
      current,
    },
  })
}

export function getData(
  url: string,
  current: number,
  size: number,
  params = {}
) {
  return request({
    url,
    method: 'get',
    params: {
      current,
      size,
      ...params,
    },
  })
}

export function getServiceTotal(params = {}) {
  return request({
    url: '/api/blade-appointment/appointment/publish/serviceTotal',
    method: 'get',
    params,
  })
}
